<template>
  <div class="login">
    <div class="card">
      <el-card shadow="always">
        <el-row>登录</el-row>
        <el-input v-model="username" placeholder="请输如用户名" clearable></el-input>
        <el-input placeholder="请输入密码" v-model="password" show-password clearable></el-input>
        <el-button type="primary" round @click="login">确认</el-button>
      </el-card>
    </div>
  </div>
</template>

<script>
import axios from "axios";

export default {
  name: "UserLogin",
  data() {
    return {

      username: "",
      password: "",

    }
  },
  methods: {
    async login() {
      await axios.post("http://localhost:7000/login", {
        user: {
          username: this.username,
          password: this.password,
        }
      }).then(response => {
        console.log(response);
        alert(response);
      }).catch(error => {
        console.log(error);
      });

    }
  }
}
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
}

.card {
  display: flex;
  height: 400px;
  width: 350px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  border-radius: 10px;
}

el-row {
  text-align: center;
}
</style>